package cn.err0r.android.shsmead;

import java.util.ArrayList;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

public class RoadinfoAdpter extends BaseAdapter {

	private ArrayList<String> roadinfo;
	private Context ctx;
	public RoadinfoAdpter(Context ctx,ArrayList<String> roadinfo){
		this.roadinfo = roadinfo;
		this.ctx = ctx;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return roadinfo.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return roadinfo.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LinearLayout lin1 = new LinearLayout(ctx);  
        lin1.setOrientation(LinearLayout. VERTICAL);
        LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(  
                LayoutParams. FILL_PARENT, LayoutParams.WRAP_CONTENT);
        
        lp2.topMargin = 10;
        lp2.leftMargin = 8;
        lp2.bottomMargin = 10;
		TextView tv = new TextView(ctx);
		tv.setTextColor(Color.WHITE);
		tv.setText(Html.fromHtml(roadinfo.get(position)));
		lin1.addView( tv, lp2 );  
		return lin1;
	}

}
